using System.Reflection;
namespace EPiSugar.EntityAdapter.PropertyBinders
{
    public class PagePropertyBinder : PropertyBinder
    {
        private readonly PageProperty readFrom;

        public PagePropertyBinder(PageProperty readFrom, PropertyInfo destinationProperty)
            : base(readFrom.ToString(), destinationProperty)
        {
            this.readFrom = readFrom;
        }

        public override void Bind(EPiServer.Core.PageData sourcePage, object toInstance)
        {
            switch (readFrom)
            {
                case PageProperty.PageName:
                    SetValue(toInstance, sourcePage.PageName);
                    break;
                case PageProperty.PageStartPublish:
                    SetValue(toInstance, sourcePage.StartPublish);
                    break;
                case PageProperty.PageStopPublish:
                    SetValue(toInstance, sourcePage.StopPublish);
                    break;
            }
        }
    }
}
